﻿namespace PLCS.Domain.Processes;

/// <summary>
/// 触发条件
/// </summary>
public class Trigger : BaseEntity
{
    /// <summary>
    /// 后台数据键
    /// </summary>
    public string? BackDataKey { get; set; }

    /// <summary>
    /// 后台数据路径
    /// </summary>
    public string? BackDataPath { get; set; }

    /// <summary>
    /// 是否从PLC读取数据
    /// </summary>
    public bool IsReadFromPLC { get; set; }

    /// <summary>
    /// IP地址
    /// </summary>
    public string? IpAddress { get; set; }

    /// <summary>
    /// DB号
    /// </summary>
    public int DBNumber { get; set; }

    /// <summary>
    /// 偏移量
    /// </summary>
    public int Offset { get; set; }

    /// <summary>
    /// 长度
    /// </summary>
    public int Size { get; set; }

    /// <summary>
    /// 数据类型
    /// </summary>
    public DataType DataType { get; set; }

    /// <summary>
    /// 比较条件
    /// </summary>
    public ComparisonType ComparisonType { get; set; }

    /// <summary>
    /// 比较值
    /// </summary>
    public string CompareValue { get; set; }

    public Trigger()
    {
    }

    public Trigger(string backDataKey, string backDataPath, ComparisonType comparisonType, string compareValue)
    {
        BackDataKey = backDataKey;
        BackDataPath = backDataPath;
        ComparisonType = comparisonType;
        CompareValue = compareValue;
    }
}